<!DOCTYPE html>
<html lang="zh" xmlns:th="http://www.thymeleaf.org">
<head>
    <th:block th:include="include :: header('修改小程序轮播图')"/>
    <th:block th:include="include :: bootstrap-fileinput-css"/>
    <th:block th:include="include :: select2-css"/>
</head>
<body class="white-bg">
<div class="wrapper wrapper-content animated fadeInRight ibox-content">
    <!--/*@thymesVar id="appletBanner" type="com.ruoyi.applet.appletBanner.domain.AppletBanner"*/-->
    <form class="form-horizontal m" id="form-appletBanner-edit" th:object="${appletBanner}">
        <input name="id" th:field="*{id}" type="hidden">
        <div class="col-xs-12">
            <div class="form-group">
                <label class="col-sm-3 control-label">轮播图标题：</label>
                <div class="col-sm-8">
                    <input name="bannerTitle" th:field="*{bannerTitle}" class="form-control" type="text">
                </div>
            </div>
        </div>
        <div class="col-xs-12">
            <div class="form-group">
                <label class="col-sm-3 control-label">轮播图跳转路径：</label>
                <div class="col-sm-8">
                    <input name="bannerUrl" th:field="*{bannerUrl}" class="form-control" type="text">
                </div>
            </div>
        </div>
        <div class="form-group">
            <label class="col-sm-3 control-label">资源类型：</label>
            <div class="col-sm-8">
                <select name="resourceType" class="form-control m-b">
                    <option value="1" th:field="*{resourceType}">轮播图资源</option>
                    <option value="2" th:field="*{resourceType}">普通图片资源</option>
                </select>
            </div>
        </div>
        <div class="col-xs-12">
            <div class="form-group">
                <label class="col-sm-3 control-label">轮播图地址：</label>
                <div class="col-sm-8">
                    <input type="hidden" name="bannerImg" th:field="*{bannerImg}">
                    <div class="file-loading">
                        <input class="form-control file-upload" id="bannerImg" name="file" type="file">
                    </div>
                </div>
            </div>
        </div>
    </form>
</div>
<th:block th:include="include :: footer"/>
<th:block th:include="include :: bootstrap-fileinput-js"/>
<th:block th:include="include :: select2-js"/>
<script th:inline="javascript">

    let prefix = ctx + "applet/appletBanner";

    $("#form-appletBanner-edit").validate({
        focusCleanup: true
    });

    function submitHandler() {
        if ($.validate.form()) {
            $.operate.save(prefix + "/edit", $('#form-appletBanner-edit').serialize());
        }
    }

    $(".file-upload").each(function (i) {
        let val = $("input[name='" + this.id + "']").val()
        $(this).fileinput({
            uploadUrl: '/applet/appletBanner/upload',
            initialPreviewAsData: true,
            initialPreview: [val],
            maxFileCount: 1,
            autoReplace: true
        }).on('fileuploaded', function (event, data, previewId, index) {
            $("input[name='" + event.currentTarget.id + "']").val(data.response.url)
        }).on('fileremoved', function (event, id, index) {
            $("input[name='" + event.currentTarget.id + "']").val('')
        })
        $(this).fileinput('_initFileActions');
    });
</script>
</body>
</html>